<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>视差滚动html+css 实现</title>
    <style>
        * {
            box-sizing: border-box;
        }

        html,
        body {
            padding: 0;
            margin: 0;
        }

        html {
            /* 需要隐藏最外层不可见区域以使视差生效 */
            overflow: hidden;
        }

        body {
            width: 100vw;
            height: 100vh;
            perspective: 100px;
            transform-style: preserve-3d;
            /* 3D的容器要允许overflow才能生效 */
            overflow-y: auto;
        }


        .list-item {
            position: relative;
            width: 100%;
            height: 100vh;
            overflow: hidden;
        }


        .item-image {
            /* position: absolute; */
            width: 100%;
            height: 100%;
            /* 这句是关键 */
            transform: translateZ(-50px) scale(2.4);
            z-index: -1;
        }

        /* .item-image::before {
            position: absolute;
            content: "";
            display: block;
            width: 100%;
            height: 100%;
            transition: all 0.3s ease;
            background-color: rgba(0, 0, 0, .4);
        } */

        .item-image img {
            display: block;
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .item-text {
            position: absolute;
            left: 50%;
            top: 50%;
            font-size: 20px;
        }
    </style>
</head>

<body> 
    <div class="main">
        <section class="list-item">
            <div class="item-image">
                <img src="images/firstBG.jpg" alt="img-1">
            </div>
        </section>
        <section class="list-item">
            <div class="item-image">
                <img src="images/secondBG.jpg" alt="img-2">
            </div>
        </section>
        <section class="list-item">
            <div class="item-image">
                <img src="images/thirdBG.jpg" alt="img-3">
            </div>
            <div class="item-text">
                <div class="text-title">第二季</div>
                <div class="text-desc">广告</div>
            </div>
        </section>
        <section class="list-item">
            <div class="item-image">
                <img src="images/4.jpg" alt="img-4">
            </div>
        </section>
        <section class="list-item">
            <div class="item-image">
                <img src="images/5.jpg" alt="img-5">
            </div>
        </section>
    </div>
</body>

</html>